package com.sskj.fca.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.fca.bean.RollMsg;
import com.sskj.fca.bean.RollPointsBean;
import com.sskj.fca.http.HttpConfig;
import com.sskj.fca.ui.fragment.RollCompareFragment;

/**
 * Created by QinKang on 2018/12/29.
 */

public class RollCompareFragmentPresenter extends BasePresenter<RollCompareFragment> {

    /**
     * Roll点页面信息
     */
    public void getRollMsg() {
        httpService.rollMsg()
                .tag(this)
                .execute(new JsonCallBack<HttpData<RollMsg>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<RollMsg>> response) {
                        HttpData httpData = response.body();
//                        ToastUtil.showShort(httpData.msg);
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.updataUI((RollMsg) httpData.getData());
                        }
                    }
                });
    }

    /**
     * Roll点数
     */
    public void getRollPoints() {
        httpService.rollPoints()
                .tag(this)
                .execute(new JsonCallBack<HttpData<RollPointsBean>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<RollPointsBean>> response) {
                        HttpData httpData = response.body();
                        ToastUtil.showShort(httpData.msg);
//                        mView.setRollPoints((RollPointsBean) httpData.getData());
                        if (httpData.getStatus() == HttpConfig.OK) {
                            mView.setRollPoints((RollPointsBean) httpData.getData());
                        }
                    }
                });
    }


}




